<?php
/**
 * Created by 项目.
 * User: xuguopeng
 * Date: 7/10/21
 * Time: 10:51 PM
 */

namespace app\api\model;


use think\model\concern\SoftDelete;

class GrActivity extends BaseModel
{
    use SoftDelete;


    public function imgs()
    {
        return $this->hasMany('GrActivityImg','activity_id','id')->order('id asc');
    }

    public function getStartTimeAttr($value,$data)
    {
        if($value) {
            if(date('Y-m-d',$value) == date('Y-m-d',$data['end_time'])) {
                return date('Y-m-d',$value);
            } else {
                return date('Y-m-d H:i',$value);
            }
        }
    }

    public function getEndTimeAttr($value,$data)
    {
        if($value) {
            if(date('Y-m-d',$value) == date('Y-m-d',$data['start_time'])) {
                return date('H:i',$data['start_time']).'-'.date('H:i',$value);
            } else {
                return date('Y-m-d H:i',$value);
            }
        }
    }
}